#include "widget.h"
#include "ui_widget.h"
//#include "qpushbutton.h"
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{

        ui->setupUi(this);
//       ui->Widget->setWindowTitle("窗口1");
      QWidget*one=new QWidget;
      one->setWindowTitle("窗口2");
       one->resize(300,300);

       QPushButton *Btn2=new QPushButton("按钮2",one);
         Btn2->move(100,150);

         QPushButton *Btn3=new QPushButton("open",this);
           Btn3->move(180,100);

       connect(ui->Btn1,&QPushButton::clicked,this,[=](){
           this->close();
           one->show();
       });
       connect(Btn2,&QPushButton::clicked,one,[=](){
           one->hide();
           this->show();
       });
       connect(Btn3,&QPushButton::clicked,one,[=](){
               if(Btn3->text()=="close")
               {
                one->close();
                Btn3->setText("open");
                                    }
               else{
                   one->show();
                   Btn3->setText("close");
               }

       });
}

Widget::~Widget()
{
    delete ui;
}

